<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改目录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-folder-edit" th:object="${folder}">
            <input id="id" name="id" th:field="*{id}"  type="hidden">
			<input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
			<div class="form-group">	
				<label class="col-sm-3 control-label">上级栏目：</label>
				<div class="col-sm-8">
					<div class="input-group">
					<input class="form-control" type="text" onclick="selectFolderTree()" id="treeName" readonly="true" th:field="*{parentName}">
					<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">栏目名称：</label>
				<div class="col-sm-8">
					<input id="folderName" name="folderName" th:field="*{folderName}" class="form-control" type="text" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">URL KEY：</label>
				<div class="col-sm-8">
					<input id="folderKey" name="folderKey" th:field="*{folderKey}" class="form-control" type="text">
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">描述：</label>
				<div class="col-sm-8">
					<input id="content" name="content" th:field="*{content}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">排序：</label>
				<div class="col-sm-8">
					<input id="sort" name="sort" th:field="*{sort}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<label class="radio-inline">
						<input type="radio" name="status"  th:if="${folder.status == 1}" th:value="1"  checked> 显示
					</label>
					<label class="radio-inline">
						<input type="radio" name="status"  th:if="${folder.status == 2}" th:value="2" checked> 隐藏
					</label>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">跳转地址：</label>
				<div class="col-sm-8">
					<input id="jumpUrl" name="jumpUrl" th:field="*{jumpUrl}" class="form-control" type="text">
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "question/folder";
		$("#form-folder-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			},
			focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-folder-edit').serialize());
	        }
	    }
        /*栏目管理-修改-选择部门树*/
        function selectFolderTree() {
            var folderId = $("#treeId").val();
            if(folderId > 0) {
                var options = {
                    title: '部门选择',
                    width: "380",
                    url: prefix + "/selectDeptTree/" + $("#treeId").val(),
                    callBack: doSubmit
                };
                $.modal.openOptions(options);
            } else {
                $.modal.alertError("父部门不能选择");
            }
        }
        function doSubmit(index, layero){
            var tree = layero.find("iframe")[0].contentWindow.$._tree;
            if ($.tree.notAllowParents(tree)) {
                var body = layer.getChildFrame('body', index);
                $("#treeId").val(body.find('#treeId').val());
                $("#treeName").val(body.find('#treeName').val());
                layer.close(index);
            }
        }
	</script>
</body>
</html>
